var util = require('../../utils/util.js');  
Page({

  /**
   * 页面的初始数据
   */
  data: {
    addtell: {
      addtellHidden: true, //弹出框显示/隐藏,
    },
  },
  //  点击时间组件确定事件  
  bindTimeChange: function (e) {
    this.setData({
      addtell:{
        times: e.detail.value
      }
    })
  },
  footAddtell: function () {
    var that = this;
    //打开弹出框
    this.setData({
      addtell: {
        addtellHidden: false,
        contract_info: '',
        times: that.data.now
      }
    })
  },
  modalConfirm: function () {
    var endtime = this.data.addtell.times;
    var time = new Date;
    var starttime = util.formatTime(new Date()); 
    var year = time.getFullYear()
    var month = time.getMonth() < 9 ? '0' + (time.getMonth() + 1) : (time.getMonth() + 1);
    var day = time.getDate() < 10 ? '0' + time.getDate() : time.getDate();
    var deptno = this.data.deptno;
    endtime = year + "/" + month + "/" + day + " " + endtime + ":00";
    console.log(starttime)
    console.log(endtime)
    var that = this;
    wx.request({
      url: 'http://192.168.1.6:8080/WeChatJSON//sendSignIn',
      data:{
        deptno: deptno, 
        endtime: endtime,
        starttime: starttime
      },
      method: 'GET',
      header: {
        'content-type': 'application/json'
      },
      success:function(res){
        console.log(res)
        wx.showToast({
          title: '发布成功',
        })
      },
      fail:function(res){
        console.log(res)
        wx.showToast({
          title: '发布失败',
        })
      }
    }),
    //弹出框确认操作
    that.setData({
      addtell: {
        addtellHidden: true,
      },
    });
  },
  modalCancel: function () {
    //弹出框取消操作
    this.setData({
      addtell: {
        addtellHidden: true,
      }
    })
  },
  onLoad:function(options){
    var time = new Date;
    var hours = time.getHours() < 10 ? '0' + time.getHours() : time.getHours();
    var min = time.getMinutes() < 10 ? '0' + time.getMinutes() : time.getMinutes();
    console.log(hours + ":" + min+":00")
    this.setData({
      deptno:options.deptno,
      now: hours + ":" + min,
      dname:options.dname
    })
  }
})